#ifndef VIA_IMG_H__
#define VIA_IMG_H__

#include <windows.h>
#include <tchar.h>
#include <process.h>

typedef BOOL (*VIAREADMEMORY_FUNC) (HANDLE h, PBYTE pDst, PBYTE pSrc, size_t size);

typedef enum VIA_COLORFORMAT {
	VIA_CF_GRAY = 0,
		VIA_CF_BGR,
		VIA_CF_RGB,
		VIA_CF_BGRA,
		VIA_CF_ARGB,
		VIA_CF_YUV
} VIA_COLORFORMAT;

namespace nVIA {
	class CBitmap;
}

class nVIA::CBitmap {
public:
	CBitmap() {
		m_bits = NULL; 
		m_bufSize = 0; 
		reset();
	}
	CBitmap(int width, int height, int pitch, VIA_COLORFORMAT format) {
		m_bits = NULL; 
		m_bufSize = 0;
		reset();
		Init(width, height, pitch, format);
	}
	~CBitmap() {Release();}

	BOOL	Init(int width, int height, int pitch, VIA_COLORFORMAT format);
	void	Release();

	int	Width() { return m_width; }
	int	Height()	{ return m_height; }
	int	Pitch()	{ return m_pitch; }
	BYTE*	Bits()	{ return m_bits; }
	BITMAPINFO*	Info() { return &m_biInfo; }
// 	void	SetWidth(int width) { m_width = width; }
// 	void	SetHeight(int height) { m_height = height; }
// 	void	SetPitch(int pitch) { m_pitch = pitch; }
// 	void	SetBits(BYTE* bits) { m_bits = bits; }
	//void	ReadBitsFrom(BYTE* bits);

private:
	void	reset() {
		m_width = 0;
		m_height = 0;
		m_pitch = 0;
	}

protected:
	int	m_width;
	int	m_height;
	int	m_pitch;
	BYTE*	m_bits;
	int	m_bufSize;
	BITMAPINFO	m_biInfo;

	VIA_COLORFORMAT m_format;
};

#endif//VIA_IMG_H__